Skip to content

Expose thread.toJSON() on the public Thread type#235

Closed
jacehwang wants to merge 1 commit intovercel:mainfrom
jacehwang:fix/thread-tojson-public-type
Closed

Expose thread.toJSON() on the public Thread type#235
jacehwang wants to merge 1 commit intovercel:mainfrom
jacehwang:fix/thread-tojson-public-type

Conversation

@jacehwang
Copy link

Summary

  • add toJSON(): SerializedThread to the public Thread interface
  • add a consumer-facing type regression test for import type { Thread } from "chat"
  • include a patch changeset for the public type fix

Problem

ThreadImpl already exposes toJSON() at runtime and the docs/examples use thread.toJSON(), but the public Thread type in dist/index.d.ts did not include that method. This caused consumer builds to fail with:

Property 'toJSON' does not exist on type 'Thread<...>'

Testing

  • pnpm validate

@vercel
Copy link
Contributor

vercel bot commented Mar 13, 2026

@jacehwang is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@haydenbleasel
Copy link
Member

Hey @jacehwang, thanks for catching this and putting up the fix! 🙌

This has actually already been fixed on maintoJSON(): SerializedThread is already on the public Thread interface (line 955 in types.ts).

The type regression test is a nice idea though! If we wanted to add something like that, we'd probably lean toward vitest's expectTypeOf/assertType rather than shelling out to tsc with a temp project — lighter weight and less fragile. But appreciate the thought!

Closing this one out since the fix is already in. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants